﻿using System.Collections.Specialized;
using System.IO;

namespace MyWcfRestLib.Files
{
    class DeviceOpParams : FileOpParams
    {
        public const string DeviceNameKey = "device_name";

        public DeviceOpParams(string basePath, NameValueCollection requestQueryParams, Stream requestBody = null)
            : base(basePath, requestQueryParams, requestBody)
        {
            // Fix path string
            DeviceName = (string)QueryParams[DeviceNameKey];
            if (null != DeviceName)
            {
                DeviceName = DeviceName.Trim(InvalidFileNameChars);
            }

            if (string.IsNullOrEmpty(DeviceRoot))
            {
                DeviceRoot = DeviceName;
            }
        }

        public string DeviceName { get; private set; }

        public override bool IsValid
        {
            get { return UtilityFunctions.IsValidPathName(DeviceName); }
        }
    }
}
